From 446985cf1aa4d9aaf905cbc037c908386d357dcf Mon Sep 17 00:00:00 2001 From: Kalita Alexey Date: Wed, 18 Jan 2017 10:56:22 +0300 Subject: [PATCH] Added tests for building an example as a library --- tests/build.rs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/tests/build.rs b/tests/build.rs index e4871a58d..c62513ebd 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -1890,6 +1890,82 @@ fn cargo_platform_specific_dependency_wrong_platform() { assert!(lockfile.contains("bar")) } +#[test] +fn example_as_lib() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex" + crate-type = ["lib"] + "#) + .file("src/lib.rs", "") + .file("examples/ex.rs", ""); + + assert_that(p.cargo_process("build"), execs().with_status(0)); +} + +#[test] +fn example_as_rlib() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex" + crate-type = ["rlib"] + "#) + .file("src/lib.rs", "") + .file("examples/ex.rs", ""); + + assert_that(p.cargo_process("build"), execs().with_status(0)); +} + +#[test] +fn example_as_dylib() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex" + crate-type = ["dylib"] + "#) + .file("src/lib.rs", "") + .file("examples/ex.rs", ""); + + assert_that(p.cargo_process("build"), execs().with_status(0)); +} + +#[test] +fn example_as_proc_macro() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex" + crate-type = ["proc-macro"] + "#) + .file("src/lib.rs", "") + .file("examples/ex.rs", ""); + + assert_that(p.cargo_process("build"), execs().with_status(0)); +} + #[test] fn example_bin_same_name() { let p = project("foo") -- 2.30.2